#ifndef _BQ275X0_BATTERY_H_
#define _BQ275X0_BATTERY_H_

#define BQ275X0_CMD_CNTL    0x00
#define BQ275X0_CMD_AR      0x02
#define BQ275X0_CMD_ARTTE   0x04
#define BQ275X0_CMD_TEMP    0x06
#define BQ275X0_CMD_VOLT    0x08
#define BQ275X0_CMD_FLAGS   0x0A
#define BQ275X0_CMD_NAC     0x0C
#define BQ275X0_CMD_FAC     0x0E
#define BQ275X0_CMD_RM      0x10
#define BQ275X0_CMD_FCC     0x12
#define BQ275X0_CMD_AI      0x14
#define BQ275X0_CMD_TTE     0x16
#define BQ275X0_CMD_TTF     0x18
#define BQ275X0_CMD_SI      0x1A
#define BQ275X0_CMD_STTE    0x1C
#define BQ275X0_CMD_MLI     0x1E
#define BQ275X0_CMD_MLTTE   0x20
#define BQ275X0_CMD_AE      0x22
#define BQ275X0_CMD_AP      0x24
#define BQ275X0_CMD_TTECP   0x26
#define BQ275X0_CMD_CC      0x2A
#define BQ275X0_CMD_SOC     0x2C

#define BQ275X0_EXT_CMD_DCAP        0x3C
#define BQ275X0_EXT_CMD_DFCLS       0x3E
#define BQ275X0_EXT_CMD_DFBLK       0x3F
#define BQ275X0_EXT_CMD_DFD         0x40
#define BQ275X0_EXT_CMD_DFDCKS      0x60
#define BQ275X0_EXT_CMD_DFDCNTL     0x61
#define BQ275X0_EXT_CMD_DNAMELEN    0x62
#define BQ275X0_EXT_CMD_DNAME       0x63
#define BQ275X0_EXT_CMD_APPSTAT     0x6A

#define BQ275X0_CNTLDATA_CONTROL_STATUS         0x0000
#define BQ275X0_CNTLDATA_DEVICE_TYPE            0x0001
#define BQ275X0_CNTLDATA_FW_VERSION             0x0002
#define BQ275X0_CNTLDATA_DF_CHECKSUM            0x0004
#define BQ275X0_CNTLDATA_RESET_DATA             0x0005
#define BQ275X0_CNTLDATA_PREV_MACWRITE          0x0007
#define BQ275X0_CNTLDATA_CHEM_ID                0x0008
#define BQ275X0_CNTLDATA_BATL_ENABLE            0x000D
#define BQ275X0_CNTLDATA_BATL_DISABLE           0x000E
#define BQ275X0_CNTLDATA_SET_HIBERNATE          0x0011
#define BQ275X0_CNTLDATA_CLEAR_HIBERNATE        0x0012
#define BQ275X0_CNTLDATA_SET_SLEEP_PLUS         0x0013
#define BQ275X0_CNTLDATA_CLEAR_SLEEP_PLUS       0x0014
#define BQ275X0_CNTLDATA_SEALED                 0x0020
#define BQ275X0_CNTLDATA_IT_ENABLE              0x0021
#define BQ275X0_CNTLDATA_CAL_MODE               0x0040
#define BQ275X0_CNTLDATA_RESET                  0x0041
#define BQ275X0_CNTLDATA_ROM_MODE               0x0F00

#ifndef BATTERY_OVER_TEMP_LOW
#define BATTERY_OVER_TEMP_LOW       10
#endif
#ifndef BATTERY_OVER_TEMP_HIGH
#define BATTERY_OVER_TEMP_HIGH      440
#endif

enum {
    BQ275X0_CNTLSTATUS_QEN,
    BQ275X0_CNTLSTATUS_VOK,
    BQ275X0_CNTLSTATUS_RUP_DIS,
    BQ275X0_CNTLSTATUS_LDMD,
    BQ275X0_CNTLSTATUS_SLEEP,
    BQ275X0_CNTLSTATUS_SNOOZE,
    BQ275X0_CNTLSTATUS_HIBERNATE,
    BQ275X0_CNTLSTATUS_BIT7,
    BQ275X0_CNTLSTATUS_BIT8,
    BQ275X0_CNTLSTATUS_BIT9,
    BQ275X0_CNTLSTATUS_BCA,
    BQ275X0_CNTLSTATUS_CCA,
    BQ275X0_CNTLSTATUS_CSV,
    BQ275X0_CNTLSTATUS_SS,
    BQ275X0_CNTLSTATUS_FAS,
    BQ275X0_CNTLSTATUS_BIT15,
};

enum {
    BQ275X0_FLAGS_DSG,
    BQ275X0_FLAGS_SOCF,
    BQ275X0_FLAGS_SOC1,
    BQ275X0_FLAGS_BAT_DET,
    BQ275X0_FLAGS_WAIT_ID,
    BQ275X0_FLAGS_OCV_GD,
    BQ275X0_FLAGS_BIT6, 
    BQ275X0_FLAGS_BIT7,
    BQ275X0_FLAGS_CHG,
    BQ275X0_FLAGS_FC,
    BQ275X0_FLAGS_XCHG,
    BQ275X0_FLAGS_CHG_INH,
    BQ275X0_FLAGS_BIT12,
    BQ275X0_FLAGS_BIT13,
    BQ275X0_FLAGS_OTD,
    BQ275X0_FLAGS_OTC,
};

enum {
    BQ275X0_OP_CONFIG_TEMPS,
    BQ275X0_OP_CONFIG_BATL_CTL,
    BQ275X0_OP_CONFIG_BATG_POL,
    BQ275X0_OP_CONFIG_BATL_POL,
    BQ275X0_OP_CONFIG_RMFCC,
    BQ275X0_OP_CONFIG_SLEEP,
    BQ275X0_OP_CONFIG_IDSELEN,
    BQ275X0_OP_CONFIG_GNDSEL,
    BQ275X0_OP_CONFIG_RSNS0,
    BQ275X0_OP_CONFIG_RSNS1,
    BQ275X0_OP_CONFIG_IWAKE,
    BQ275X0_OP_CONFIG_PFC_CFG0,
    BQ275X0_OP_CONFIG_PFC_CFG1,
    BQ275X0_OP_CONFIG_I2C_NACK,
    BQ275X0_OP_CONFIG_BATG_OVR,
    BQ275X0_OP_CONFIG_RESCAP,
};

enum {
    BQ275X0_APP_STATUS_LU_PROF,
};

#define BQ275X0_PFC_SELECTION_MASK      (0x3 << BQ275X0_OP_CONFIG_PFC_CFG0)
#define BQ275X0_CURR_WAKEUP_FUNC_MASK   (0x7 << BQ275X0_OP_CONFIG_PFC_IWAKE)

struct bq275x0_platform_data {
        unsigned pmic_BATLOW;
        unsigned pmic_BATGD;
};

int bq275x0_battery_soc(void);
int bq275x0_battery_health(void);
int bq275x0_battery_voltage(void);
int bq275x0_battery_current(void);
int bq275x0_battery_temperature(void);
#endif
